<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var sum=1;
        var a=prompt("请输入一个正整数","4");
        for(var i=1; i<=parseInt(a);i++){
            sum=sum*i;
        }
        document.write(a+"的阶乘为："+sum);
    </script>
</body>
</html>